﻿using System;

namespace TowerOfHanoi
{
    class Program
    {
        public static string A = "A";
        public static string B = "B";
        public static string C = "C";
        public static long Level;
        public static long Step = 0;
        public static void Move(long x, string P, string Q, string R)
        //用于将x个圆盘从P柱经由Q柱移动到R柱，输出过程，返回移动次数
        {
            if (x == 1)
            {
                Console.WriteLine("Move plate from {0} to {1} ",P,R);
                Step++;
            }
            //只需要移动一个圆盘时，直接从P柱移动到R柱
            else
            {
                Move(x - 1, P, R, Q);
                //将底盘上的x-1个圆盘由P柱移动到Q柱
                Move(1, P, Q, R);
                //将底盘移至R柱
                Move(x - 1, Q, P, R);
                //将底盘上的x-1个圆盘移至R柱
            }
        }
        public static void Main(string[] args)
        {
            Console.Write("请输入层数：");
            Level = long.Parse(Console.ReadLine());
            Console.WriteLine();
            Move(Level, A, B, C);
            Console.Write("总步骤为" + Step);
            Console.ReadKey();
        }
    }
}
